package com.gu.dao;

import com.gu.entity.VehicleRefuelingInfo;
import com.gu.entity.excelExportEntity.VehicleRefuelingInfoExp;
import com.gu.enumeration.vehicleTypeEnum.VehicleTypeEnum;
import com.gu.mapper.VehicleRefuelingInfoMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: gusongliao
 * @Description:
 * @createDate 2023/01/05 19:30
 */
@Repository
public class VehicleRefuelingInfoDao {

    @Autowired
    private VehicleRefuelingInfoMapper vehicleRefuelingInfoMapper;
    
    public int deleteByPrimaryKey(Integer id) {
        return vehicleRefuelingInfoMapper.deleteByPrimaryKey(id);
    }

    public int insert(VehicleRefuelingInfo record) {
        return vehicleRefuelingInfoMapper.insert(record);
    }

    public int insertSelective(VehicleRefuelingInfo record) {
        return vehicleRefuelingInfoMapper.insertSelective(record);
    }

    public VehicleRefuelingInfo selectByPrimaryKey(Integer id) {
        return vehicleRefuelingInfoMapper.selectByPrimaryKey(id);
    }

    public int updateByPrimaryKeySelective(VehicleRefuelingInfo record) {
        return vehicleRefuelingInfoMapper.updateByPrimaryKeySelective(record);
    }

    public int updateByPrimaryKey(VehicleRefuelingInfo record){
        return vehicleRefuelingInfoMapper.updateByPrimaryKey(record);
    }

    public List<VehicleRefuelingInfo> getAllVehicleRefuelingInfo(String vehicleSelectorParam,String submitTimeStart
            ,String submitTimeEnd
            ,String createTimeStart
            ,String createTimeEnd
            ,Integer matchRule
    ){
        return vehicleRefuelingInfoMapper.getAllVehicleRefuelingInfo(vehicleSelectorParam,submitTimeStart,submitTimeEnd,createTimeStart,createTimeEnd,matchRule);
    }

    public int delete(String[] dataIds) {
        return vehicleRefuelingInfoMapper.deleteByDataIds(dataIds);
    }

    public List<String> selectAllInputId(){
        return vehicleRefuelingInfoMapper.selectAllInputId();
    }

    public VehicleRefuelingInfo selectByInputId(String inputId){
        return vehicleRefuelingInfoMapper.selectByInputId(inputId);
    }

    public List<VehicleRefuelingInfoExp> selectSummaryDataByParam(String vehicleSelectorParam
            , String submitTimeStart
            , String submitTimeEnd
            , String createTimeStart
            , String createTimeEnd
            , VehicleTypeEnum vehicleTypeEnum
            , Integer matchRule
    ) {
        String vehicleType = vehicleTypeEnum.getVehicleType();
        if ("公务".equals(vehicleType)) {
            vehicleType = "";
        }
        return vehicleRefuelingInfoMapper.selectSummaryDataByParam(vehicleSelectorParam, submitTimeStart, submitTimeEnd, createTimeStart, createTimeEnd, vehicleTypeEnum.getVehicleTypeSettingOperatorName(), vehicleType, matchRule);
    }
}
